<template>
	<view>
		<view class="box">
			<radio-group @change="radioChange">
				<view class="uni-flex uni-column">
					<radio :value="item.value" :checked="item.checked?item.checked:item.ischeck" v-for="(item,index) in contacts" :key="index" color="#00D5A2">
						<view class="name uni-flex uni-column">
							<view>
								<text style="font-size: 32upx;">{{item.name}}</text>
							</view>
							<view>
								<text style="color: #C2C2C2;">{{item.name}}</text>
							</view>
						</view>
					</radio>
				</view>
			</radio-group>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				/* 联系人 */
				contacts: [{
						name: '全部',
						value: '1',
						checked: 'true',
						ischeck:false
					},
					{
						name: '仅自己',
						value: '2',
						ischeck:false
					},
					{
						name: '仅老师',
						value:'3',
						ischeck:false
					},
					{
						name: '仅家长',
						value: '4',
						ischeck:false
					}
				],
				Audience_scope:[],
				obj:0
			}
		},
		onNavigationBarButtonTap() {
			uni.$emit('look-obj',{Audience_scope:this.Audience_scope})
			uni.navigateBack({
				delta:1
			})
		},
		onLoad(e) {
			console.log('e',e);
			if(this.Audience_scope.length==0){
				this.Audience_scope = e.obj
			}
			console.log('onLoda',e.obj);
			this.obj = e.obj
			this.obj = this.obj+''
			this.check()
		},
		methods: {
			radioChange:function(evt){
				this.Audience_scope = evt.detail.value;
			},
			check(){
				for (var i = 0; i < this.contacts.length; i++) {
					if(this.obj == this.contacts[i].value){
						console.log('对');
						this.contacts[i].ischeck = true
					}else{
						console.log('错');
						this.contacts[i].ischeck = false
					}
				}
			}
		}
	}
</script>

<style scoped>

	.contact-scroll {
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		align-items: center;
		width: 100vw;
		height: calc(100vh - 90upx);
	}

	.box {
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		align-items: center;
		width: 94%;
		margin: auto;
	}

	.divider {
		margin-top: 30upx;
		margin-bottom: 30upx;
		width: 100%;
		padding: 5upx 0;
		color: #000;
	}

	.divider-text {
		margin-left: 20upx;
	}


	.name {
		font-size: 35upx;
		padding: 8px;
	}
</style>
